package com.example.mockito;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
 * 代码简洁性
 */
public class OneLinerStubs {
    List<String> mockList = when(mock(List.class).listIterator()).thenThrow(RuntimeException.class).getMock();
    @Test
    void listIterator() {
        Assertions.assertThrows(RuntimeException.class, () -> {
            mockList.listIterator();
        });
    }
}
